with Generic_Expressions;

function Generic_Expressions.Eval(X: Expression) return Item is

begin
   case X.Model
      when Valeur => return X.Val;
      when Unaire =>
         case X.Operator

            when '+' => return Generic_Expressions.Eval(X.Argument.all);
            when '-' => return -1 * Generic_Expressions.Eval(X.Argument.all);
         end case;

      when Binaire =>
         case X.Operator
            when '+' =>
              return Generic_Expressions.Eval(X.Avant.All) + Generic_Expressions.Eval(X.Apres.all);

            when '-' =>
               return Generic_Expressions.Eval(X.Avant.All) - Generic_Expressions.Eval(X.Apres.All);

            when '*' =>
               return Generic_Expressions.Eval(X.Avant.All) * Generic_Expressions.Eval(X.Apres.All);

            when '/' =>
               return Generic_Expressions.Eval(X.Avant.All) / Generic_Expressions.Eval(X.Apres.All);
         end case;
   end case;

end Generic_Expressions.Eval;
